﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TransCend.Exceptions
{
    public class BaseException : Exception 
    {
        private Exception originalException = null;

        public BaseException()
            : base()
        {

        }

        public BaseException(int errorcode)
        {
            ErrorCode = errorcode;
        }

        public BaseException(string message)
            : base(message)
        {

        }

        public BaseException(string message, Exception e) : base(message, e)
        {
            originalException = e;
        }

        public BaseException(int errorCode, string message, Exception e) : this(message, e)
        {
            ErrorCode = errorCode;
        }

        public int ErrorCode
        {
            get;
            set;
        }

        /// <summary>
        /// 返回引发异常
        /// </summary>
        /// <returns></returns>
        public Exception GetOriginalException()
        {
            if (originalException != null)
            {
                return originalException;
            }
            return this;
        }

    }
}
